package com.visionet.waveletData.web.vo.account;

import com.google.common.collect.Sets;
import com.visionet.waveletData.web.entity.account.Role;
import com.visionet.waveletData.web.vo.BaseVo;
import com.visionet.waveletData.web.vo.business.UserInfoVo;

import org.apache.commons.lang3.builder.ToStringBuilder;
import org.springside.modules.utils.Collections3;

import java.util.Date;
import java.util.List;
import java.util.Set;

/**
 * 用户.
 * 
 * @author xt
 */
public class UserVo extends BaseVo {

	public UserVo() {
	}

	public UserVo(Long id) {
		this.id = id;
	}

	private String loginName="";
	private String aliasName;
	private String password;
	private String plainPassword;
	private String passwordSalt;

	private Long orgId;
	private String orgName;

	private Long secId;
	private Integer isLockSec;
	private Integer isLock;
	private Date lastLogin;

	private Set<Role> roleList = Sets.newHashSet();
    private String roleIds;

	/*--------VO field--------------*/
	private Long phoneNumber;
	private String validateCode;
	private Short allowLoginFromMobile;

	private String birthday; // 生日
	private String title; // 职位
	private String email; // 电子邮件
	private String address; // 所在地
	private String website; // 个人网站
	private Long departmentId;
	private Integer gender;
	private String trueName;
    private Boolean daySign;
    private String lastLoginTime;

	private UserInfoVo userInfo;

	public String getRoleNames() {
		if(roleList == null) return null;
		return Collections3.extractToString(roleList, "name", ", ");
	}
	
	public UserInfoVo getUserInfo() {
		return userInfo;
	}

	public void setUserInfo(UserInfoVo userInfo) {
		this.userInfo = userInfo;
	}

	public Short getAllowLoginFromMobile() {
		return allowLoginFromMobile;
	}

	public void setAllowLoginFromMobile(Short allowLoginFromMobile) {
		this.allowLoginFromMobile = allowLoginFromMobile;
	}

	public Long getOrgId() {
		return orgId;
	}

	public void setOrgId(Long orgId) {
		this.orgId = orgId;
	}

	public String getOrgName() {
		return orgName;
	}

	public void setOrgName(String orgName) {
		this.orgName = orgName;
	}


	public String getLoginName() {
		return loginName;
	}

	public void setLoginName(String loginName) {
		this.loginName = loginName;
	}

	public String getAliasName() {
		return aliasName;
	}

	public void setAliasName(String aliasName) {
		this.aliasName = aliasName;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getPlainPassword() {
		return plainPassword;
	}

	public void setPlainPassword(String plainPassword) {
		this.plainPassword = plainPassword;
	}

	public String getPasswordSalt() {
		return passwordSalt;
	}

	public void setPasswordSalt(String passwordSalt) {
		this.passwordSalt = passwordSalt;
	}

	public Long getSecId() {
		return secId;
	}

	public void setSecId(Long secId) {
		this.secId = secId;
	}

	public Integer getIsLockSec() {
		return isLockSec;
	}

	public void setIsLockSec(Integer isLockSec) {
		this.isLockSec = isLockSec;
	}

	public Integer getIsLock() {
		return isLock;
	}

	public void setIsLock(Integer isLock) {
		this.isLock = isLock;
	}

	public Date getLastLogin() {
		return lastLogin;
	}

	public void setLastLogin(Date lastLogin) {
		this.lastLogin = lastLogin;
	}

	public Set<Role> getRoleList() {
		return roleList;
	}

	public void setRoleList(Set<Role> roleList) {
		this.roleList = roleList;
	}

	public String getRoleIds() {
		return roleIds;
	}

	public void setRoleIds(String roleIds) {
		this.roleIds = roleIds;
	}

	public Long getPhoneNumber() {
		return phoneNumber;
	}

	public void setPhoneNumber(Long phoneNumber) {
		this.phoneNumber = phoneNumber;
	}

	public String getValidateCode() {
		return validateCode;
	}

	public void setValidateCode(String validateCode) {
		this.validateCode = validateCode;
	}

	public String getBirthday() {
		return birthday;
	}

	public void setBirthday(String birthday) {
		this.birthday = birthday;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public String getWebsite() {
		return website;
	}

	public void setWebsite(String website) {
		this.website = website;
	}

	public Long getDepartmentId() {
		return departmentId;
	}

	public void setDepartmentId(Long departmentId) {
		this.departmentId = departmentId;
	}

	public Integer getGender() {
		return gender;
	}

	public void setGender(Integer gender) {
		this.gender = gender;
	}
	

	public String getTrueName() {
		return trueName;
	}

	public void setTrueName(String trueName) {
		this.trueName = trueName;
	}


    public Boolean getDaySign() {
        return daySign;
    }

    public void setDaySign(Boolean daySign) {
        this.daySign = daySign;
    }

    public String getLastLoginTime() {
        return lastLoginTime;
    }

    public void setLastLoginTime(String lastLoginTime) {
        this.lastLoginTime = lastLoginTime;
    }

    @Override
	public String toString() {
		return ToStringBuilder.reflectionToString(this);
	}

    @Override
    public int hashCode(){
        return this.getId()==null?1:this.getId().hashCode();
    }
	@Override
	public boolean equals(Object obj) {
		if (null == obj || !(obj instanceof UserVo)) {
			return false;
		}
		UserVo user = (UserVo) obj;
		if (user.getId() == null) {
			return false;
		}
		return user.getId().equals(this.id);
	}

}